package com.itheima.d0_homework.timu4;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.Random;
import java.util.function.Consumer;

public class Test {
    public static void main(String[] args) {
        ArrayList<ProductItem> product = new ArrayList<>();
        Random random = new Random();

        ProductItem p1 = new ProductItem(1, random.nextInt(100000000), 1, "机械键盘", 317.97);
        ProductItem p2 = new ProductItem(2, random.nextInt(100000000), 2, "益生菌", 157.97);
        ProductItem p3 = new ProductItem(3, random.nextInt(100000000), 3, "u盘", 118.95);
        ProductItem p4 = new ProductItem(4, random.nextInt(100000000), 4, "蓝牙耳机", 298.97);

        product.add(p1);
        product.add(p2);
        product.add(p3);
        product.add(p4);

        ArrayList<ArrayList<ProductItem>> newProduct = new ArrayList<>();

        newProduct.add(product);

        Iterator<ArrayList<ProductItem>> iterator = newProduct.iterator();
        while (iterator.hasNext()) {
            ArrayList<ProductItem> next = iterator.next();
            for (int i = 0; i < next.size(); i++) {
                ProductItem productItem = next.get(i);
                System.out.println(productItem.getProductItemId() + "," + productItem.getProductItemNumber() + ","
                        + productItem.getProductNumber() + ","
                        + productItem.getProductName() + "," + productItem.getPrice());
            }

        }

    }
}
